//
// Created on 4/3/2024.
//
// Node APIs are not fully supported. To solve the compilation error of the interface cannot be found,
// please include "napi/native_api.h".

#include "ClipPathViewComponentInstance.h"
// #include <glog/logging.h>
namespace rnoh {
    ClipPathViewComponentInstance::ClipPathViewComponentInstance(Context context)
        : CppComponentInstance(std::move(context)) {}

    void ClipPathViewComponentInstance::insertChild(ComponentInstance::Shared childComponentInstance,
                                                    std::size_t index) {
        m_stackNode.insertChild(childComponentInstance->getLocalRootArkUINode(), index);
    }

    ClipPathViewStackNode &ClipPathViewComponentInstance::getLocalRootArkUINode() { return m_stackNode; }

    void ClipPathViewComponentInstance::onPropsChanged(SharedConcreteProps const &props) {
        CppComponentInstance::onPropsChanged(props);
        if (auto p = std::dynamic_pointer_cast<const facebook::react::RNCClipPathViewProps>(props)) {
//             this->getNapiProps(props);
            LOG(WARNING) << "[clx] <ClipPathViewComponentInstance::setProps> d: " << p->d;
            LOG(WARNING) << "[clx] <ClipPathViewComponentInstance::setProps> mOpacity: " << p->opacity;
            LOG(WARNING) << "[clx] <ClipPathViewComponentInstance::setProps> mMask: " << p->mask;
            LOG(WARNING) << "[clx] <ClipPathViewComponentInstance::setProps> mOldMask: " << p->oldMask;
            LOG(WARNING) << "[clx] <ClipPathViewComponentInstance::setProps> mFillColor: " << p->fillColor;
            LOG(WARNING) << "[clx] <ClipPathViewComponentInstance::setProps> mFillOpacity: " << p->fillOpacity;
            LOG(WARNING) << "[clx] <ClipPathViewComponentInstance::setProps> mFillRule: " << p->fillRule;
            LOG(WARNING) << "[clx] <ClipPathViewComponentInstance::setProps> strokeColor: " << p->strokeColor;
            LOG(WARNING) << "[clx] <ClipPathViewComponentInstance::setProps> strokeOpacity: " << p->strokeOpacity;
            LOG(WARNING) << "[clx] <ClipPathViewComponentInstance::setProps> strokeWidth: " << p->strokeWidth;
            LOG(WARNING) << "[clx] <ClipPathViewComponentInstance::setProps> strokeCap: " << p->strokeCap;
            LOG(WARNING) << "[clx] <ClipPathViewComponentInstance::setProps> strokeJoin: " << p->strokeJoin;
            LOG(WARNING) << "[clx] <ClipPathViewComponentInstance::setProps> strokeMiter: " << p->strokeMiter;
            LOG(WARNING) << "[clx] <ClipPathViewComponentInstance::setProps> strokeStart: " << p->strokeStart;
            LOG(WARNING) << "[clx] <ClipPathViewComponentInstance::setProps> strokeEnd: " << p->strokeEnd;
            LOG(WARNING) << "[clx] <ClipPathViewComponentInstance::setProps> shadowColor: " << p->shadowColor;
            LOG(WARNING) << "[clx] <ClipPathViewComponentInstance::setProps> shadowOpacity: " << p->shadowOpacity;
            LOG(WARNING) << "[clx] <ClipPathViewComponentInstance::setProps> shadowRadius: " << p->shadowRadius;
            LOG(WARNING) << "[clx] <ClipPathViewComponentInstance::setProps> shadowOffsetX: " << p->shadowOffsetX;
            LOG(WARNING) << "[clx] <ClipPathViewComponentInstance::setProps> shadowOffsetY: " << p->shadowOffsetY;
            LOG(WARNING) << "[clx] <ClipPathViewComponentInstance::setProps> shadowOffsetIsPercent: "
                      << p->shadowOffsetIsPercent;
            LOG(WARNING) << "[clx] <ClipPathViewComponentInstance::setProps> bgColor: " << p->bgColor;
            LOG(WARNING) << "[clx] <ClipPathViewComponentInstance::setProps> scale: " << p->scale;
            LOG(WARNING) << "[clx] <ClipPathViewComponentInstance::setProps> scaleX: " << p->scaleX;
            LOG(WARNING) << "[clx] <ClipPathViewComponentInstance::setProps> scaleY: " << p->scaleY;
            LOG(WARNING) << "[clx] <ClipPathViewComponentInstance::setProps> scaleOrigin: " << p->scaleOrigin;
            LOG(WARNING) << "[clx] <ClipPathViewComponentInstance::setProps> scaleOriginX: " << p->scaleOriginX;
            LOG(WARNING) << "[clx] <ClipPathViewComponentInstance::setProps> scaleOriginY: " << p->scaleOriginY;
            LOG(WARNING) << "[clx] <ClipPathViewComponentInstance::setProps> scaleIsPercent: " << p->scaleIsPercent;
            this->getLocalRootArkUINode().setD(p->d);
            this->getLocalRootArkUINode().setFillOpacity(p->opacity);
            this->getLocalRootArkUINode().setMask(p->mask);
            this->getLocalRootArkUINode().setOldMask(p->oldMask);
            this->getLocalRootArkUINode().setFillColor(p->fillColor);
            this->getLocalRootArkUINode().setFillOpacity(p->fillOpacity);

            this->getLocalRootArkUINode().setStrokeColor(p->strokeColor);
            this->getLocalRootArkUINode().setStrokeWidth(p->strokeWidth);
            this->getLocalRootArkUINode().setStrokeCap(p->strokeCap);
            this->getLocalRootArkUINode().setStrokeJoin(p->strokeJoin);
            this->getLocalRootArkUINode().setStrokeMiter(p->strokeMiter);
            this->getLocalRootArkUINode().setStrokeOpacity(p->strokeOpacity);
            this->getLocalRootArkUINode().setStrokeStart(p->strokeStart);
            this->getLocalRootArkUINode().setStrokeEnd(p->strokeEnd);
            this->getLocalRootArkUINode().setBgColor(p->bgColor);
        
            this->getLocalRootArkUINode().setShadowColor(p->shadowColor);
            this->getLocalRootArkUINode().setShadowOpacity(p->shadowOpacity);
            this->getLocalRootArkUINode().setShadowRadius(p->shadowRadius);
            this->getLocalRootArkUINode().setShadowOffsetX(p->shadowOffsetX);
            this->getLocalRootArkUINode().setShadowOffsetY(p->shadowOffsetY);
            this->getLocalRootArkUINode().setShadowOffsetIsPercent(p->shadowOffsetIsPercent);
        
            this->getLocalRootArkUINode().setSc(p->scale);
            this->getLocalRootArkUINode().setScX(p->scaleX);
            this->getLocalRootArkUINode().setScY(p->scaleY);
            this->getLocalRootArkUINode().setScO(p->scaleOrigin);
            this->getLocalRootArkUINode().setScOx(p->scaleOriginX);
			this->getLocalRootArkUINode().setScOy(p->scaleOriginY);
            this->getLocalRootArkUINode().setScPercentageValue(p->scaleIsPercent);
        
            this->getLocalRootArkUINode().setTransX(p->translationX);
            this->getLocalRootArkUINode().setTransY(p->translationY);
            this->getLocalRootArkUINode().setTransPercentageValue(p->translationIsPercent);
        
            this->getLocalRootArkUINode().setRot(p->rotation);
            this->getLocalRootArkUINode().setRotO(p->rotation);
            this->getLocalRootArkUINode().setRotOx(p->rotationOx);
            this->getLocalRootArkUINode().setRotOy(p->rotationOy);
            this->getLocalRootArkUINode().setRotPercentageValue(p->rotationIsPercent);
        
			this->getLocalRootArkUINode().setAlign(p->align);
        }
    }

    void ClipPathViewComponentInstance::getNapiProps(facebook::react::Props::Shared props) {
        auto p = std::dynamic_pointer_cast<const facebook::react::RNCClipPathViewProps>(props);

        this->opacityStatus = p->opacityStatus;
        if (!p->opacityStatus) {
            this->opacity = p->opacity;
        }
        this->mask = p->mask;
        this->oldMask = p->oldMask;

        if (!p->fillColorStatus) {
            this->fillColor = p->fillColor;
        }
        this->fillColorStatus = p->fillColorStatus;

        if (!p->fillOpacityStatus) {
            this->fillOpacity = p->fillOpacity;
        }
        this->fillOpacityStatus = p->fillOpacityStatus;

        if (!p->fillRuleStatus) {
            this->fillRule = p->fillRule;
        }
        this->fillRuleStatus = p->fillRuleStatus;

        if (!p->strokeColorStatus) {
            this->strokeColor = p->strokeColor;
        }
        this->strokeColorStatus = p->strokeColorStatus;

        if (!p->strokeOpacityStatus) {
            this->strokeOpacity = p->strokeOpacity;
        }
        this->strokeOpacityStatus = p->strokeOpacityStatus;

        if (!p->strokeWidthStatus) {
            this->strokeWidth = p->strokeWidth;
        }
        this->strokeWidthStatus = p->strokeWidthStatus;

        if (!p->strokeMiterStatus) {
            this->strokeMiter = p->strokeMiter;
        }
        this->strokeMiterStatus = p->strokeMiterStatus;

        this->strokeCap = p->strokeCap;
        this->strokeJoin = p->strokeJoin;

        if (!p->strokeStartStatus) {
            this->strokeStart = p->strokeStart;
        }
        this->strokeStartStatus = p->strokeStartStatus;

        if (!p->strokeEndStatus) {
            this->strokeEnd = p->strokeEnd;
        }
        this->strokeEndStatus = p->strokeEndStatus;


        if (!p->shadowColorStatus) {
            this->shadowColor = p->shadowColor;
        }
        this->shadowColorStatus = p->shadowColorStatus;

        if (!p->shadowOpacityStatus) {
            this->shadowOpacity = p->shadowOpacity;
        }
        this->shadowOpacityStatus = p->shadowOpacityStatus;

        if (!p->shadowRadiusStatus) {
            this->shadowRadius = p->shadowRadius;
        }
        this->shadowRadiusStatus = p->shadowRadiusStatus;
    
        if (!p->shadowOffsetStatus) {
            this->shadowOffsetX = p->shadowOffsetX;
            this->shadowOffsetY = p->shadowOffsetY;
            this->shadowOffsetIsPercent = p->shadowOffsetIsPercent;
        }
        this->shadowOffsetStatus = p->shadowOffsetStatus;
        this->bgColor = p->bgColor;

        this->scale = p->scale;
        this->scaleX = p->scaleX;
        this->scaleY = p->scaleY;
        this->scaleOrigin = p->scaleOrigin;
        this->scaleOriginX = p->scaleOriginX;
        this->scaleOriginY = p->scaleOriginY;
        this->scaleIsPercent = p->scaleIsPercent;
		
		this->rotation = p->rotation;
        this->rotationOx = p->rotationOx;
        this->rotationOy = p->rotationOy;
        this->rotationIsPercent = p->rotationIsPercent;
    
        this->translationX = p->translationX;
        this->translationY = p->translationY;
        this->translationIsPercent = p->translationIsPercent;

        this->align = p->align;
    }
} // namespace rnoh